import 'package:cbec_app/generated/json/base/json_field.dart';
import 'package:cbec_app/generated/json/new_image_ad_entity.g.dart';
import 'dart:convert';

import 'content_data.dart';
export 'package:cbec_app/generated/json/new_image_ad_entity.g.dart';

@JsonSerializable()
class NewImageAdEntity extends ContentData {
  String? indicator = '';
  @JSONField(name: "border_width")
  int? borderWidth = 0;
  @JSONField(name: "show_method")
  String? showMethod = '';
  @JSONField(name: "page_margin")
  int? pageMargin = 0;
  String? count = '';
  @JSONField(name: "image_fill_style")
  String? imageFillStyle = '';
  @JSONField(name: "overlap_height")
  int? overlapHeight = 0;
  String? uuid = '';
  String? size = '';
  @JSONField(name: "corner_type")
  String? cornerType = '';
  @JSONField(name: "sub_entry")
  List<NewImageAdSubEntry>? subEntry = [];
  @JSONField(name: "image_style")
  String? imageStyle = '';
  @JSONField(name: "swipe_time")
  int? swipeTime = 0;

  NewImageAdEntity() {
    type = 'new_image_ad'; // 直接在构造函数中赋值
  }

  factory NewImageAdEntity.fromJson(Map<String, dynamic> json) => $NewImageAdEntityFromJson(json);

  @override
  Map<String, dynamic> toJson() => $NewImageAdEntityToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }

  @override
  ContentData fromJson(Map<String, dynamic> json) {
    return NewImageAdEntity.fromJson(json);
  }
}

@JsonSerializable()
class NewImageAdSubEntry {
  @JSONField(name: "link_type")
  String? linkType = '';
  @JSONField(name: "image_height")
  int? imageHeight = 0;
  @JSONField(name: "image_url")
  String? imageUrl = '';
  @JSONField(name: "link_url")
  String? linkUrl = '';
  @JSONField(name: "link_title")
  String? linkTitle = '';
  @JSONField(name: "image_width")
  int? imageWidth = 0;
  String? title = '';
  @JSONField(name: "link_id")
  int? linkId = 0;

  NewImageAdSubEntry();

  factory NewImageAdSubEntry.fromJson(Map<String, dynamic> json) => $NewImageAdSubEntryFromJson(json);

  Map<String, dynamic> toJson() => $NewImageAdSubEntryToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}
